import numpy as np
import theano.tensor as T
import theano

# 激励函数示例
x = T.dmatrix('x')
s = 1 / (1 + T.exp(-x))  # logistic or soft step
logistic = theano.function([x], s)
print(logistic([[0, 1], [3, 4]]))

# 多输出函数示例
a, b = T.dmatrices('a', 'b')
diff = a - b
abs_diff = abs(diff)
diffs = diff ** 2
f = theano.function([a, b], [diff, abs_diff, diffs])
# print(f([[1,2],[3,4]],[[1,1],[1,1]]))
x1, x2, x3 = (f([[1, 2], [3, 4]], [[1, 1], [1, 1]]))

# 函数参数名字
x, y, w = T.dscalars('x', 'y', 'w')
z = (x + y) * w
f = theano.function([x, theano.In(y, value=1), theano.In(w, value=2, name='weight')], z)
result = f(23, weight=3)
print(result)

# def f(a,b=1,c=2)
#     return (a+b)*c
